<template>
  <el-dialog width="40%"
             title="宠物物品"
             :close-on-click-modal="false"
             :visible.sync="visible">
    <el-form :model="dataForm"
             label-width="100px" label-position="right">
      <div style="margin-left: 20%">
        <el-form-item label="宠物ID：">
          {{dataForm.pbUserId}}
        </el-form-item>
        <el-form-item label="宠物等级：">
          {{dataForm.petLevel}}
        </el-form-item>
        <el-form-item label="宠物昵称：">
          {{dataForm.name}}
        </el-form-item>
        <el-form-item label="闯关级别：">
          {{dataForm.roundLevel}}
        </el-form-item>
        <el-form-item label="获得金币：">
          {{dataForm.integral}}
        </el-form-item>
        <el-form-item label="宠物经验：">
          {{dataForm.petExp}}
        </el-form-item>
      </div>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          pbUserId: '',
          type: '',
          name: '',
          petLevel: '',
          petExp: '',
          roundLevel: '',
          integral: ''
        },
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/picbook/pbpet/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm = data.data.pbPet
              }
            })
          }
        })
      },
    }
  }
</script>
<style lang="less" scoped>
  .el-form-item {
    margin-bottom: 0px;
  }
</style>
